package com.zzgele.qmzb.api.web;

import com.alibaba.boot.dubbo.annotation.DubboConsumer;
import com.cnc.cloudv.live.channelManage.ChannelManage;
import com.github.pagehelper.PageInfo;
import com.zzgele.qmzb.api.core.Result;
import com.zzgele.qmzb.api.core.ResultGenerator;
import com.zzgele.qmzb.api.model.VideoWhiteList;
import com.zzgele.qmzb.api.service.*;
import com.zzgele.qmzb.api.utils.PageUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Martin on 2017/07/13.
 */
@RestController
@RequestMapping("/video")
public class WhiteVideoController {
    private final Logger logger = LoggerFactory.getLogger(WhiteVideoController.class);
    @DubboConsumer
    private VideoListService videoListService;
    @DubboConsumer
    private VideoWhiteListService videoWhiteListService;

    @RequestMapping("/recommend/list")
    public Result recommend(Long login_uid,Integer page,Integer page_size ){
        if(page==null)
            page=1;
        if(page_size==null){
            page_size=20;
        }
        PageUtil.startPage(page, page_size);
        HashMap map = new HashMap();
        map.put("login_uid",login_uid);
        map.put("status",1);
        List<HashMap> list = videoListService.recommandList(map);
        for(HashMap item:list){
            String s=(String)item.get("file_name");
            item.put("fileName",OssController.Bucket.get("qmwlzb-one")+s);
            item.remove("file_name");
            //预留字段
            item.put("shareUrl","");
            item.put("isLike",0);
            item.put("commentNum",0);

        }
        HashMap videoListHashMap = PageUtil.getPageInfoHashMap(new PageInfo(list));

        return ResultGenerator.genSuccessResult(videoListHashMap);
    }

}
